﻿using System;
using System.Web.UI;

namespace VPLink2013.Webcontrols
{
    public class Logo: WebcontrolVPLink
    {
        public string LogoSite = string.Empty;

        protected override void Render(HtmlTextWriter writer)
        {
            try
            {
                string strImage = string.Empty;
                string strHtml = string.Empty;

                Template = "webcontrol Logo";
                SetUrlPageCrt();

                if (LogoSite == "1")
                {
                    if (urlPageCrt.StartsWith(string.Format(@"{0}/services",siteUrl)))
                    { 
                        if (urlPageCrt.StartsWith(string.Format(@"{0}/services/production/mercure", siteUrl)))
                        {
                            strImage = "Mercure/smallLogoMercure.jpg";
                            strHtml = "<a href='http://vplink/services/production/Mercure/Pages/default.aspx'><img class=\"vplink\" src=\"/_layouts/15/VPLink2013/images/" + strImage + "\" alt=\"Accueil\" border=\"0\"/></a>";
                        }
                        if (urlPageCrt == string.Format(@"{0}/services/production/Mercure/Pages/default.aspx", siteUrl))
                        {
                            strImage = "Mercure/LogoMercure.jpg";
                            strHtml = "<a href='http://vplink/services/production/Mercure/Pages/default.aspx'><img class=\"vplink\" src=\"/_layouts/15/VPLink2013/images/" + strImage + "\" alt=\"Accueil\" border=\"0\"/></a>";
                        }
                    }
                }
                else
                {
                    strImage = "vplink2014.png";
                    string strClass = "logo_vp";
                    if (!isDefaultPage)
                    {
                        strImage = "header_int2014.png";
                        strClass = "logo_vp inner_page";
                    }
                    string defaultPage = getDefaultPageValue();
                    strHtml = "<div class=\"" + strClass + "\"><a href=\"" + defaultPage + "\"><img class=\"vplink\" src=\"/_layouts/15/VPLink2013/images/" + strImage + "\" alt=\"Accueil\" border=\"0\"/></a></div>";
                }

                if (!string.IsNullOrEmpty(strImage))
                {
                    sbHtml.Append(strHtml);
                    base.Render(writer);
                }
            }
            catch (Exception e)
            {

            }
        }
    }
}
